<?php /* SVN: $Id: $ */ ?>
<div class="affiliateCashWithdrawals form js-ajax-form-container">
    <div class="clearfix widget-affiliate-information-block">
     	<div class="affiliate-information widget-affiliate-information">
         	<ul class="widget-link">
             	<li>
            	   	<?php echo $this->Html->link(__l('Affiliates'), array('controller' => 'affiliates', 'action' => 'index'),array('title' => __l('Affiliates'))); ?>
                </li>
            </ul>
        </div>
    </div>
 <div class="affiliate-information">
	<div class="content-info">
    	<?php echo __l('The requested amount will be deducted from your affiliate commission amount and the amount will be blocked until it get approved or rejected by the administrator. Once it\'s approved, the requested amount will be sent to your paypal account. In case of failure, the amount will be refunded to your affiliate commission amount.'); ?>
    </div>

<div class="user-edit-form-block">
	<?php 		
		if($this->Auth->user('user_type_id') == ConstUserTypes::User){
			$min = Configure::read('affiliate.payment_threshold_for_threshold_limit_reach');	
			$cleared_amount = $user['User']['commission_line_amount'];
			$transaction_fee = Configure::read('affiliate.site_commission_amount');
			$transaction_fee_type = Configure::read('affiliate.site_commission_type');
			if(!empty($transaction_fee)){
				$transactions = ($transaction_fee_type == 'amount') ? $transaction_fee : $transaction_fee.'%';
				$transactions = '<br/>'.__l('Site Transaction Fee').': '.Configure::read('site.currency').$transactions;
			}
			else{
				$transactions = '';
			}	
		}
	?>

	<?php	echo $this->Form->create('AffiliateCashWithdrawal', array('class' => "normal  js-ajax-form {container:'js-ajax-form-container',responsecontainer:'js-responses'}"));
			echo $this->Form->input('user_id', array('type' => 'hidden')); ?>
			<div class="clearfix affiliatecashwithdrawal-block">
			<div class="clearfix">
    			<div class="grid_left">
        			<?php
        			echo $this->Form->input('amount',array('label' => __l('Amount'),'after' => Configure::read('site.currency') . '<span class="info">' . sprintf(__l('Minimum withdraw amount: '.Configure::read('site.currency').'%s <br/>  Total affiliate Commission amount earned: '.Configure::read('site.currency').'%s  %s'),$min, $cleared_amount, $transactions . '</span>')));
                	?>
          	    </div>
				</div>
				<div class="submit-block grid_left clearfix">
						<?php echo $this->Form->submit(__l('Request Withdraw'));?>
			    </div>
	          </div>
            <?php echo $this->Form->end();?>
   
</div>
</div>
</div>
